<?php 
use Mirage\Web;
echo Web::app()->getFlash('result');
?>
<table id="tbltask">
    
</table>
<div id="pager"></div>
<!--<div id="dialog-confirm" title="Confirm">
    <p>
        <span class="ui-icon-alert" style="float:left; margin:0 7px 20px 0;display: none">
            
        </span>Are you sure want to cancel(or send this names)#names?
    </p>
</div>-->
<!--<table>
    <?php //foreach($data as $row): ?>
    <tr>
        <td><?php //echo $row['id']; ?></td>
        <td><?php //echo $row['date']; ?></td>
        <td><?php //echo $row['task']; ?></td>
        <td><?php //echo $row['status']; ?></td>
        <td><?php //echo $row['problem']; ?></td>
        <td><?php //echo $row['solution']; ?></td>
        <td><?php //echo $row['remarks']; ?></td>
        <td><a href="<?php //echo Web::app()->getController()->createUrl('view/id/'.$row['id']); ?>">View</a></td>
        <td><a href="<?php //echo Web::app()->getController()->createUrl('edit/id/'.$row['id']); ?>">Edit</a></td>
        <td><a href="<?php //echo Web::app()->getController()->createUrl('delete/id/'.$row['id']); ?>">Delete</a></td>
    </tr>
    <?php //endforeach; ?>
</table>-->
<!--<a id="btnAdd" href="<?php echo Web::app()->getController()->createUrl('add'); ?>">Add</a>-->
<script>
$(document).ready(function(){
    $('#btnAdd').button();
})
</script>
<script>
$(document).ready(function(){
    
    
    $("#sidemenu").slidemenu({
        title:'Menus',
        menu:[
            {label:'Add Movie',icon:'ui-icon-plusthick',link:'',htmlOptions:{'width':'a','class':''}},
            {label:'Update Movie',icon:'ui-icon-pencil',link:''},
            {label:'Delete Movie',icon:'ui-icon-trash',link:''}
        ],
        htmlOptions:{style:'width:100px'}
    });
    
    $('#accordion').accordion({ collapsible: true,active: false,autoHeight:true});
    
    jQuery("#tbltask").jqGrid({ 
//        url: url, 
        datatype: "json", 
        colNames:[
            'ID',
            'Date',
            'Task',
            'Status',
            'Problem',
            'Solution',
            'Remarks',
            '',
        ], 
        colModel:[ 
            {name:'id',index:'id',width:'7%'}, 
            {name:'date',index:'date',width:'10%'}, 
            {name:'task',index:'task',width:'30%'},
            {name:'status',index:'status',width:'10%'},
            {name:'problem',index:'problem',width:'20%'},
            {name:'solution',index:'solution',width:'20%'},
            {name:'remarks',index:'remarks',width:'10%'},
            {name:'action',index:'action',width:'10%'},
        ], 
        rowNum:<?php echo \Mirage\Base\Config::app()->param['initialLimit'] ?>, 
        rowList:<?php echo \Mirage\Base\Config::app()->param['limit'] ?>, 
        pager: '#pager', 
        width:780,
        height:400,
        sortname: 'id', 
        viewrecords: true, 
        sortorder: "desc", 
	loadComplete: function(data){
            var viewUrl='<?php echo Web::app()->getController()->createUrl('view/id/');  ?>';
            var editUrl='<?php echo Web::app()->getController()->createUrl('edit/id/');  ?>';
            for(var i=0; i < data.rows.length; i++) {
                id = data.rows[i].cell[0];
                
                icon = '<div title="View Task" style="float:left;margin-right:2px;" class="ui-pg-button ui-corner-all ui-action-div action-view" url="'+viewUrl+id +'"><span class="ui-icon ui-icon-search"></span></div>' +
                    '<div title="Edit Task" style="float:left;margin-right:2px;" class="ui-pg-button ui-corner-all ui-action-div action-edit" url="'+editUrl+id +'"><span class="ui-icon ui-icon-pencil"></span></div>' + 
                    '<div style="float:left;margin-right:2px;" class="ui-pg-button ui-corner-all ui-action-div"><span class="ui-icon ui-icon-trash"></span></div>';
                $('#tbltask > tbody > tr#' + id ).children('td:last').html(icon);
            }
            
//            for(var i=0;i < ids.length;i++){
//                var cl = ids[i];
//                be = "<input style='height:22px;width:20px;' type='button' value='E' onclick=\"jQuery('#tbltask').editRow('"+cl+"');\" />";
//                se = "<input style='height:22px;width:20px;' type='button' value='S' onclick=\"jQuery('#tbltask').saveRow('"+cl+"');\" />"; 
//                ce = "<input style='height:22px;width:20px;' type='button' value='C' onclick=\"jQuery('#tbltask').restoreRow('"+cl+"');\" />";
//                jQuery("#rowed2").jqGrid('setRowData',ids[i],{act:be+se+ce});
//            }
            
        },        
        caption:"Accomplishment Report"
    }); 
    
    jQuery('.ui-action-div').live('mouseover',function(){
        $(this).addClass('ui-state-hover');
    })
    jQuery('.ui-action-div').live('mouseout',function(){
        $(this).removeClass('ui-state-hover');
    })
//    jQuery('.ui-action-div').live('click',function(){
//        $("#dialog-confirm").dialog({autoOpen:true,open: function(event, ui) { $('.ui-dialog-titlebar-close').hide()}});
//    })

    
    
    jQuery("#tbltask").jqGrid('navGrid','#pager',{edit:false,add:true,del:false}); 
    
        $( ".demo button:first" ).button({
            icons: {
                primary: "ui-icon-plusthick"
            }
        }).next().button({
            icons: {
                primary: "ui-icon-locked"
            }
        }).next().button({
            icons: {
                primary: "ui-icon-gear",
                secondary: "ui-icon-triangle-1-s"
            }
        }).next().button({
            icons: {
                primary: "ui-icon-gear",
                secondary: "ui-icon-triangle-1-s"
            },
            text: false
        });

})
</script>